﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using YULI.Common;
using System.Text;

namespace YULI.Web.admin.settings
{
    public partial class nav_config : Web.UI.ManagePage
    {
        protected int nav_id = 0;
        protected Model.navigation model = new Model.navigation();
        protected void Page_Load(object sender, EventArgs e)
        {
            this.nav_id = YULIRequest.GetQueryInt("nav_id");
            if (this.nav_id > 0)
            {
                model = new BLL.navigation().GetModel(this.nav_id);
            }

            if (!Page.IsPostBack)
            {
            }
        }

        #region 绑定导航菜单=============================
        protected string NavBind(int parent_id)
        {
            BLL.navigation bll = new BLL.navigation();
            DataTable dt = bll.GetList(0, YULIEnums.NavigationEnum.Admin.ToString(), 1);

            StringBuilder strNav = new StringBuilder();
            strNav.Append("<option value=\"0\">无父级导航</option>");
            foreach (DataRow dr in dt.Rows)
            {
                string Id = dr["id"].ToString();
                int ClassLayer = int.Parse(dr["class_layer"].ToString());
                string Title = dr["title"].ToString().Trim();

                if (ClassLayer == 1)
                {
                   //
                }
                else
                {
                    Title = "├ " + Title;
                    Title = Utils.StringOfChar(ClassLayer - 1, "　") + Title;
                }

                string option = "<option value=\"" + Id + "\">" + Title + "</option>";
                if (parent_id == Convert.ToInt32(Id) && parent_id != 0)
                {
                    option = "<option value=\"" + Id + "\" selected=\"selected\">" + Title + "</option>";
                }

                strNav.Append(option);
            }

            return strNav.ToString();
        }
        #endregion
    }
}